package com.ljfiction.book.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.ljfiction.book.R;

/**
 * Created by Android on 2018/2/1.
 */

public class NewVersionDialog {
    private Dialog mDialog;
    private ProgressBar progressBar;
    private TextView textView;

    public NewVersionDialog(Context context) {
        mDialog = new Dialog(context, R.style.AppTheme2);
        Window window = mDialog.getWindow();
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = 0;
        window.setAttributes(wl);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        window.setGravity(Gravity.CENTER);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        mDialog.setContentView(R.layout.dialog_newversion);
        progressBar = mDialog.findViewById(R.id.notification_newversion);
        textView = mDialog.findViewById(R.id.notification_newversontv);
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.setCancelable(false);
    }

    public void show() {
        if (mDialog != null) {
            mDialog.show();
        }
    }

    public void setProgressBar(int baifenbi) {
        progressBar.setProgress(baifenbi);
        textView.setText(baifenbi+"%");
    }


}
